home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 6 / QRZ Ham Radio Callsign Database - Volume 6.iso / pc / files / dsp / dspkgctr.z / dspkgctr / gcc / varasm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-08  |  58.0 KB  |  2,166 lines

  1. /* Output variables, constants and external declarations, for GNU compiler.
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.  
  4.     $Id: varasm.c,v 1.17 92/04/01 17:01:25 pete Exp $
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 1, or (at your option)
  11. any later version.
  12.  
  13. GNU CC is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with GNU CC; see the file COPYING.  If not, write to
  20. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  21.  
  22.  
  23. /* This file handles generation of all the assembler code
  24.    *except* the instructions of a function.
  25.    This includes declarations of variables and their initial values.
  26.  
  27.    We also output the assembler code for constants stored in memory
  28.    and are responsible for combining constants with the same value.  */
  29.  
  30. #include <stdio.h>
  31. #include <setjmp.h>
  32. /* #include <stab.h> */
  33. #include "config.h"
  34. #include "rtl.h"
  35. #include "tree.h"
  36. #include "flags.h"
  37. #include "expr.h"
  38. #if ! defined( _INTELC32_ )
  39. #include "hard-reg-set.h"
  40. #else
  41. #include "hardrset.h"
  42. #endif
  43.  
  44. #include "obstack.h"
  45.  
  46. #if defined( DSP96000 ) || defined( DSP56000 )
  47. #include "c-tree.h"
  48. #endif
  49.  
  50. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  51.  
  52. /* File in which assembler code is being written.  */
  53.  
  54. extern FILE *asm_out_file;
  55.  
  56. extern struct obstack *current_obstack;
  57. extern struct obstack *saveable_obstack;
  58. extern struct obstack permanent_obstack;
  59. #define obstack_chunk_alloc xmalloc
  60. extern int xmalloc ();
  61.  
  62. /* Number for making the label on the next
  63.    constant that is stored in memory.  */
  64.  
  65. int const_labelno;
  66.  
  67. /* Number for making the label on the next
  68.    static variable internal to a function.  */
  69.  
  70. int var_labelno;
  71.  
  72. /* Nonzero if at least one function definition has been seen.  */
  73. static int function_defined;
  74.  
  75. extern FILE *asm_out_file;
  76.  
  77. #if defined( _MSDOS )
  78. void error ( char *, ... );
  79. void error_with_file_and_line ( char * file, ... );
  80. void error_with_decl ( tree decl, ... );
  81. void warning ( char * s, ... );
  82. #endif
  83.  
  84. static char *compare_constant_1 ();
  85. static void record_constant_1 ();
  86. void assemble_name ();
  87. void output_addressed_constants ();
  88. void output_constant ();
  89. void output_constructor ();
  90.  
  91. #ifdef EXTRA_SECTIONS
  92. static enum in_section {no_section, in_text, in_data, EXTRA_SECTIONS} in_section
  93.   = no_section;
  94. #else
  95. static enum in_section {no_section, in_text, in_data} in_section
  96.   = no_section;
  97. #endif
  98.  
  99. /* Define functions like text_section for any extra sections.  */
  100. #ifdef EXTRA_SECTION_FUNCTIONS
  101. EXTRA_SECTION_FUNCTIONS
  102. #endif
  103.  
  104. /* Tell assembler to switch to text section.  */
  105.  
  106. void
  107. text_section ()
  108. {
  109. #if defined( DSP56000 ) || defined( DSP96000 )
  110.  
  111.   extern int counter_pragma_seen;
  112.  
  113. /* we want to ensure that #pragmas that affect the counters are always
  114.    observed. */
  115.   if (counter_pragma_seen || in_section != in_text)
  116.     {
  117.       counter_pragma_seen = 0; 
  118. #else
  119.   if (in_section != in_text)
  120.     {
  121. #endif
  122.       fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
  123.       in_section = in_text;
  124.     }
  125. }
  126.  
  127. /* Tell assembler to switch to data section.  */
  128.  
  129. void
  130. data_section ()
  131. {
  132. #if defined( DSP56000 ) || defined( DSP96000 )
  133.  
  134.   extern int counter_pragma_seen;
  135.  
  136. /* we want to ensure that #pragmas that affect the counters are always
  137.    observed. */
  138.   if (counter_pragma_seen || in_section != in_data)
  139.     {
  140.       counter_pragma_seen = 0; 
  141. #else
  142.   if (in_section != in_data)
  143.     {
  144. #endif
  145.       if (flag_shared_data)
  146.     {
  147. #ifdef SHARED_SECTION_ASM_OP
  148.       fprintf (asm_out_file, "%s\n", SHARED_SECTION_ASM_OP);
  149. #else
  150.       fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  151. #endif
  152.     }
  153.       else
  154.     fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
  155.  
  156.       in_section = in_data;
  157.     }
  158. }
  159.  
  160. /* Determine if we're in the text section. */
  161.  
  162. int
  163. in_text_section ()
  164. {
  165.   return in_section == in_text;
  166. }
  167.  
  168. /* Create the rtl to represent a function, for a function definition.
  169.    DECL is a FUNCTION_DECL node which describes which function.
  170.    The rtl is stored into DECL.  */
  171.  
  172. void
  173. make_function_rtl (decl)
  174.      tree decl;
  175. {
  176.   if (DECL_RTL (decl) == 0)
  177.     DECL_RTL (decl)
  178.       = gen_rtx (MEM, DECL_MODE (decl),
  179.          gen_rtx (SYMBOL_REF, Pmode, DECL_ASSEMBLER_NAME (decl)));
  180.  
  181.   /* Record at least one function has been defined.  */
  182.   function_defined = 1;
  183. }
  184.  
  185. /* Decode an `asm' spec for a declaration as a register name.
  186.    Return the register number, or -1 if nothing specified,
  187.    or -2 if the name is not a register.  */
  188.  
  189. int
  190. decode_reg_name (asmspec)
  191.      char *asmspec;
  192. {
  193.   if (asmspec != 0)
  194.     {
  195.       int i;
  196.       extern char *reg_names[];
  197.  
  198.       for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  199.     if (!strcmp (asmspec, reg_names[i]))
  200.       break;
  201.  
  202.       if (i < FIRST_PSEUDO_REGISTER)
  203.     return i;
  204.       else
  205.     return -2;
  206.     }
  207.  
  208.   return -1;
  209. }
  210.  
  211. /* Create the DECL_RTL for a declaration for a static or external variable
  212.    or static or external function.
  213.    ASMSPEC, if not 0, is the string which the user specified
  214.    as the assembler symbol name.
  215.    TOP_LEVEL is nonzero if this is a file-scope variable.
  216.  
  217.    This is never called for PARM_DECL nodes.  */
  218.  
  219. void
  220. make_decl_rtl (decl, asmspec, top_level)
  221.      tree decl;
  222.      char *asmspec;
  223.      int top_level;
  224. {
  225.   register char *name = DECL_ASSEMBLER_NAME (decl);
  226.   int reg_number = decode_reg_name (asmspec);
  227.  
  228.   if (reg_number == -2)
  229.     {
  230.       name = (char *) obstack_alloc (saveable_obstack,
  231.                      strlen (asmspec) + 2);
  232.       name[0] = '*';
  233.       strcpy (&name[1], asmspec);
  234.     }
  235.  
  236.   /* For a duplicate declaration, we can be called twice on the
  237.      same DECL node.  Don't alter the RTL already made
  238.      unless the old mode is wrong (which can happen when
  239.      the previous rtl was made when the type was incomplete).  */
  240.   if (DECL_RTL (decl) == 0
  241.       || GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
  242.     {
  243.       DECL_RTL (decl) = 0;
  244.  
  245.       /* First detect errors in declaring global registers.  */
  246.       if (TREE_REGDECL (decl) && reg_number == -1)
  247.     error_with_decl (decl,
  248.              "register name not specified for `%s'");
  249.       else if (TREE_REGDECL (decl) && reg_number == -2)
  250.     error_with_decl (decl,
  251.              "invalid register name for `%s'");
  252.       else if (reg_number >= 0 && ! TREE_REGDECL (decl))
  253.     error_with_decl (decl,
  254.              "register name given for non-register variable `%s'");
  255.       else if (TREE_REGDECL (decl) && TREE_CODE (decl) == FUNCTION_DECL)
  256.     error ("function declared `register'");
  257.       else if (TREE_REGDECL (decl) && TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
  258.     error_with_decl (decl, "data type of `%s' isn't suitable for a register");
  259.       /* Now handle properly declared static register variables.  */
  260.       else if (TREE_REGDECL (decl))
  261.     {
  262.       int nregs;
  263.       if (pedantic)
  264.         warning ("ANSI C forbids global register variables");
  265.       if (DECL_INITIAL (decl) != 0)
  266.         {
  267.           DECL_INITIAL (decl) = 0;
  268.           error ("global register variable has initial value");
  269.         }
  270.       if (fixed_regs[reg_number] == 0
  271.           && function_defined && top_level)
  272.         error ("global register variable follows a function definition");
  273.       DECL_RTL (decl) = gen_rtx (REG, DECL_MODE (decl), reg_number);
  274.       if (top_level)
  275.         {
  276.           /* Make this register fixed, so not usable for anything else.  */
  277.           nregs = HARD_REGNO_NREGS (reg_number, DECL_MODE (decl));
  278.           while (nregs > 0)
  279.         global_regs[reg_number + --nregs] = 1;
  280.           init_reg_sets_1 ();
  281.         }
  282.     }
  283.  
  284.       /* Now handle ordinary static variables and functions (in memory).
  285.      Also handle vars declared register invalidly.  */
  286.       if (DECL_RTL (decl) == 0)
  287.     {
  288.       /* Can't use just the variable's own name for a variable
  289.          whose scope is less than the whole file.
  290.          Concatenate a distinguishing number.  */
  291.       if (!top_level && !TREE_EXTERNAL (decl) && asmspec == 0)
  292.         {
  293.           char *label;
  294.  
  295.           ASM_FORMAT_PRIVATE_NAME (label, name, var_labelno);
  296.           name = obstack_copy0 (saveable_obstack, label, strlen (label));
  297.           var_labelno++;
  298.         }
  299.  
  300.       DECL_RTL (decl) = gen_rtx (MEM, DECL_MODE (decl),
  301.                      gen_rtx (SYMBOL_REF, Pmode, name));
  302.       if (TREE_VOLATILE (decl))
  303.         MEM_VOLATILE_P (DECL_RTL (decl)) = 1;
  304.       if (TREE_READONLY (decl))
  305.         RTX_UNCHANGING_P (DECL_RTL (decl)) = 1;
  306.       MEM_IN_STRUCT_P (DECL_RTL (decl))
  307.         = (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
  308.            || TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
  309.            || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE);
  310.     }
  311.     }
  312. }
  313.  
  314. /* Output a string of literal assembler code
  315.    for an `asm' keyword used between functions.  */
  316.  
  317. void
  318. assemble_asm (string)
  319.      tree string;
  320. {
  321.   app_enable ();
  322.  
  323.   fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
  324. }
  325.  
  326. /* Output assembler code associated with defining the name of a function
  327.    as described by DECL.  */
  328.  
  329. void
  330. assemble_function (decl)
  331.      tree decl;
  332. {
  333.   rtx x, n;
  334.   char *fnname;
  335.   int align;
  336.  
  337.   /* Get the function's name, as described by its RTL.
  338.      This may be different from the DECL_NAME name used in the source file.  */
  339.  
  340.   x = DECL_RTL (decl);
  341.   if (GET_CODE (x) != MEM)
  342.     abort ();
  343.   n = XEXP (x, 0);
  344.   if (GET_CODE (n) != SYMBOL_REF)
  345.     abort ();
  346.   fnname = XSTR (n, 0);
  347.  
  348.   /* The following code does not need preprocessing in the assembler.  */
  349.  
  350.   app_disable ();
  351.  
  352.   text_section ();
  353.  
  354. #ifdef SDB_DEBUGGING_INFO
  355.   /* Make sure types are defined for debugger before fcn name is defined.  */
  356.   if (write_symbols == SDB_DEBUG)
  357.     sdbout_tags (gettags ());
  358. #endif
  359.  
  360.   /* Tell assembler to move to target machine's alignment for functions.  */
  361.  
  362.   align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
  363.   if (align > 0)
  364.     ASM_OUTPUT_ALIGN (asm_out_file, align);
  365.  
  366. #ifdef SDB_DEBUGGING_INFO
  367.   /* Output SDB definition of the function.  */
  368.   if (write_symbols == SDB_DEBUG)
  369.     sdbout_mark_begin_function ();
  370. #endif
  371.  
  372.   /* Make function name accessible from other files, if appropriate.  */
  373.  
  374.   if (TREE_PUBLIC (decl))
  375.     ASM_GLOBALIZE_LABEL (asm_out_file, fnname);
  376.  
  377.   /* Do any machine/system dependent processing of the function name */
  378. #ifdef ASM_DECLARE_FUNCTION_NAME
  379.   ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
  380. #else
  381.   /* Standard thing is just output label for the function.  */
  382.   ASM_OUTPUT_LABEL (asm_out_file, fnname);
  383. #endif /* ASM_DECLARE_FUNCTION_NAME */
  384. }
  385.  
  386. /* Assemble " .int 0\n" or whatever this assembler wants.  */
  387.  
  388. void
  389. assemble_integer_zero ()
  390. {
  391.   ASM_OUTPUT_INT (asm_out_file, const0_rtx);
  392. }
  393.  
  394. /* Assemble a string constant with the specified C string as contents.  */
  395.  
  396. void
  397. assemble_string (p, size)
  398.      unsigned char *p;
  399.      int size;
  400. {
  401.   register int i;
  402.   int excess = 0;
  403.   int pos = 0;
  404.   int maximum = 2000;
  405.  
  406.   /* If the string is very long, split it up.  */
  407.  
  408.   while (pos < size)
  409.     {
  410.       int thissize = size - pos;
  411.       if (thissize > maximum)
  412.     thissize = maximum;
  413.  
  414. #ifdef ASM_OUTPUT_ASCII
  415.       ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
  416. #else
  417.       fprintf (asm_out_file, "\t.ascii \"");
  418.  
  419.       for (i = 0; i < thissize; i++)
  420.     {
  421.       register int c = p[i];
  422.       if (c == '\"' || c == '\\')
  423.         putc ('\\', asm_out_file);
  424.       if (c >= ' ' && c < 0177)
  425.         putc (c, asm_out_file);
  426.       else
  427.         {
  428.           fprintf (asm_out_file, "\\%o", c);
  429.           /* After an octal-escape, if a digit follows,
  430.          terminate one string constant and start another.
  431.          The Vax assembler fails to stop reading the escape
  432.          after three digits, so this is the only way we
  433.          can get it to parse the data properly.  */
  434.           if (i < thissize - 1
  435.           && p[i + 1] >= '0' && p[i + 1] <= '9')
  436.         fprintf (asm_out_file, "\"\n\t.ascii \"");
  437.         }
  438.     }
  439.       fprintf (asm_out_file, "\"\n");
  440. #endif /* no ASM_OUTPUT_ASCII */
  441.  
  442.       pos += thissize;
  443.       p += thissize;
  444.     }
  445. }
  446.  
  447. /* Assemble everything that is needed for a variable or function declaration.
  448.    Not used for automatic variables, and not used for function definitions.
  449.    Should not be called for variables of incomplete structure type.
  450.  
  451.    TOP_LEVEL is nonzero if this variable has file scope.
  452.    WRITE_SYMBOLS is DBX_DEBUG if writing dbx symbol output.
  453.    The dbx data for a file-scope variable is written here.
  454.    AT_END is nonzero if this is the special handling, at end of compilation,
  455.    to define things that have had only tentative definitions.  */
  456.  
  457. void
  458. assemble_variable (decl, top_level, write_symbols, at_end)
  459.      tree decl;
  460.      int top_level;
  461.      enum debugger write_symbols;
  462.      int at_end;
  463. {
  464.   register char *name;
  465.   register int i;
  466.  
  467.   /* Do nothing for global register variables.  */
  468.  
  469.   if (GET_CODE (DECL_RTL (decl)) == REG)
  470.     return;
  471.  
  472.   /* Normally no need to say anything for external references,
  473.      since assembler considers all undefined symbols external.  */
  474.  
  475.   if (TREE_EXTERNAL (decl))
  476.     return;
  477.  
  478.   /* Output no assembler code for a function declaration.
  479.      Only definitions of functions output anything.  */
  480.  
  481.   if (TREE_CODE (decl) == FUNCTION_DECL)
  482.     return;
  483.  
  484.   /* If type was incomplete when the variable was declared,
  485.      see if it is complete now.  */
  486.  
  487.   if (DECL_SIZE (decl) == 0)
  488.     layout_decl (decl, 0);
  489.  
  490.   /* Still incomplete => don't allocate it; treat the tentative defn
  491.      (which is what it must have been) as an `extern' reference.  */
  492.  
  493.   if (DECL_SIZE (decl) == 0)
  494.     {
  495.       error_with_file_and_line (DECL_SOURCE_FILE (decl),
  496.                 DECL_SOURCE_LINE (decl),
  497.                 "storage size of static var `%s' isn't known",
  498.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  499.       return;
  500.     }
  501.  
  502.   /* The first declaration of a variable that comes through this function
  503.      decides whether it is global (in C, has external linkage)
  504.      or local (in C, has internal linkage).  So do nothing more
  505.      if this function has already run.  */
  506.  
  507.   if (TREE_ASM_WRITTEN (decl))
  508.     return;
  509.  
  510.   TREE_ASM_WRITTEN (decl) = 1;
  511.  
  512. #ifdef DBX_DEBUGGING_INFO
  513.   /* File-scope global variables are output here.  */
  514.   if (write_symbols == DBX_DEBUG && top_level)
  515.     dbxout_symbol (decl, 0);
  516. #endif
  517. #ifdef SDB_DEBUGGING_INFO
  518.   if (write_symbols == SDB_DEBUG && top_level)
  519.     sdbout_symbol (decl, 0);
  520. #endif
  521.   if (write_symbols == GDB_DEBUG)
  522.     /* Make sure the file is known to GDB even if it has no functions.  */
  523.     set_current_gdbfile (DECL_SOURCE_FILE (decl));
  524.  
  525.   /* If storage size is erroneously variable, just continue.
  526.      Error message was already made.  */
  527.  
  528.   if (! TREE_LITERAL (DECL_SIZE (decl)))
  529.     return;
  530.  
  531.   app_disable ();
  532.  
  533.   name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
  534.  
  535.   /* Handle uninitialized definitions.  */
  536.  
  537.   if (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node)
  538.     {
  539.       int size = (TREE_INT_CST_LOW (DECL_SIZE (decl))
  540.           * DECL_SIZE_UNIT (decl)
  541.           / BITS_PER_UNIT);
  542.       int rounded = size;
  543.       /* Don't allocate zero bytes of common,
  544.      since that means "undefined external" in the linker.  */
  545.       if (size == 0) rounded = 1;
  546.       /* Round size up to multiple of BIGGEST_ALIGNMENT bits
  547.      so that each uninitialized object starts on such a boundary.  */
  548.       rounded = ((rounded + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  549.          / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  550.          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  551.       if (flag_shared_data)
  552.     data_section ();
  553.       if (TREE_PUBLIC (decl))
  554.     ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded);
  555.       else
  556.     ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  557.       return;
  558.     }
  559.  
  560.   /* Handle initialized definitions.  */
  561.  
  562.   /* First make the assembler name(s) global if appropriate.  */
  563.   if (TREE_PUBLIC (decl) && DECL_NAME (decl))
  564.     ASM_GLOBALIZE_LABEL (asm_out_file, name);
  565. #if 0
  566.   for (d = equivalents; d; d = TREE_CHAIN (d))
  567.     {
  568.       tree e = TREE_VALUE (d);
  569.       if (TREE_PUBLIC (e) && DECL_NAME (e))
  570.     ASM_GLOBALIZE_LABEL (asm_out_file,
  571.                  XSTR (XEXP (DECL_RTL (e), 0), 0));
  572.     }
  573. #endif
  574.  
  575.   /* Output any data that we will need to use the address of.  */
  576.   if (DECL_INITIAL (decl))
  577.     output_addressed_constants (DECL_INITIAL (decl));
  578.  
  579.   /* Switch to the proper section for this data.  */
  580. #ifdef SELECT_SECTION
  581.   SELECT_SECTION (decl);
  582. #else
  583.   if (TREE_READONLY (decl) && ! TREE_VOLATILE (decl))
  584.     text_section ();
  585.   else
  586.     data_section ();
  587. #endif
  588.  
  589.   /* Output the alignment of this data.  */
  590.   for (i = 0; DECL_ALIGN (decl) >= BITS_PER_UNIT << (i + 1); i++);
  591.   if (i > 0)
  592.     ASM_OUTPUT_ALIGN (asm_out_file, i);
  593.  
  594.   /* Output the name(s) of this data.  */
  595.   ASM_OUTPUT_LABEL (asm_out_file, name);
  596. #if 0
  597.   for (d = equivalents; d; d = TREE_CHAIN (d))
  598.     {
  599.       tree e = TREE_VALUE (d);
  600.       ASM_OUTPUT_LABEL (asm_out_file, XSTR (XEXP (DECL_RTL (e), 0), 0));
  601.     }
  602. #endif
  603.  
  604.   if (DECL_INITIAL (decl))
  605.     /* Output the actual data.  */
  606.     output_constant (DECL_INITIAL (decl), int_size_in_bytes (TREE_TYPE (decl)));
  607.   else
  608.     /* Leave space for it.  */
  609.     ASM_OUTPUT_SKIP (asm_out_file, int_size_in_bytes (TREE_TYPE (decl)));
  610. }
  611.  
  612. /* Output something to declare an external symbol to the assembler.
  613.    (Most assemblers don't need this, so we normally output nothing.)  */
  614.  
  615. void
  616. assemble_external (decl)
  617.      tree decl;
  618. {
  619.   rtx rtl = DECL_RTL (decl);
  620.  
  621.   if (GET_CODE (rtl) == MEM && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF)
  622.     {
  623. #ifdef ASM_OUTPUT_EXTERNAL
  624.       /* Some systems do require some output.  */
  625.       ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
  626. #endif
  627.     }
  628. }
  629.  
  630. /* Output to FILE a reference to the assembler name of a C-level name NAME.
  631.    If NAME starts with a *, the rest of NAME is output verbatim.
  632.    Otherwise NAME is transformed in an implementation-defined way
  633.    (usually by the addition of an underscore).
  634.    Many macros in the tm file are defined to call this function.  */
  635.  
  636. void
  637. assemble_name (file, name)
  638.      FILE *file;
  639.      char *name;
  640. {
  641.   if (name[0] == '*')
  642.     fputs (&name[1], file);
  643.   else
  644.     ASM_OUTPUT_LABELREF (file, name);
  645. }
  646.  
  647. /* Allocate SIZE bytes writable static space with a gensym name
  648.    and return an RTX to refer to its address.  */
  649.  
  650. rtx
  651. assemble_static_space (size)
  652.      int size;
  653. {
  654.   char name[12];
  655.   char *namestring;
  656.   rtx x;
  657.   /* Round size up to multiple of BIGGEST_ALIGNMENT bits
  658.      so that each uninitialized object starts on such a boundary.  */
  659.   int rounded = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
  660.          / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  661.          * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
  662.  
  663.   if (flag_shared_data)
  664.     data_section ();
  665.   ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
  666.   ++const_labelno;
  667.  
  668.   namestring = (char *) obstack_alloc (saveable_obstack,
  669.                        strlen (name) + 2);
  670.   strcpy (namestring, name);
  671.  
  672.   x = gen_rtx (SYMBOL_REF, Pmode, namestring);
  673.   ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
  674.   return x;
  675. }
  676.  
  677. /* Here we combine duplicate floating constants to make
  678.    CONST_DOUBLE rtx's, and force those out to memory when necessary.  */
  679.  
  680. /* Chain of all CONST_DOUBLE rtx's constructed for the current function.
  681.    They are chained through the CONST_DOUBLE_CHAIN.
  682.    A CONST_DOUBLE rtx has CONST_DOUBLE_MEM != cc0_rtx iff it is on this chain.
  683.    In that case, CONST_DOUBLE_MEM is either a MEM,
  684.    or const0_rtx if no MEM has been made for this CONST_DOUBLE yet.  */
  685.  
  686. static rtx real_constant_chain;
  687.  
  688. /* Return a CONST_DOUBLE for a value specified as a pair of ints.
  689.    For an integer, I0 is the low-order word and I1 is the high-order word.
  690.    For a real number, I0 is the word with the low address
  691.    and I1 is the word with the high address.  */
  692.  
  693. rtx
  694. immed_double_const (i0, i1, mode)
  695.      int i0, i1;
  696.      enum machine_mode mode;
  697. {
  698.   register rtx r;
  699.  
  700.   if (mode == DImode && i0 == 0 && i1 == 0)
  701.     return const0_rtx;
  702.  
  703.   /* Search the chain for an existing CONST_DOUBLE with the right value.
  704.      If one is found, return it.  */
  705.  
  706.   for (r = real_constant_chain; r; r = CONST_DOUBLE_CHAIN (r))
  707.     if (CONST_DOUBLE_LOW (r) == i0 && CONST_DOUBLE_HIGH (r) == i1
  708.     && GET_MODE (r) == mode)
  709.       return r;
  710.  
  711.   /* No; make a new one and add it to the chain.  */
  712.  
  713.   r = gen_rtx (CONST_DOUBLE, mode, 0, i0, i1);
  714.  
  715.   CONST_DOUBLE_CHAIN (r) = real_constant_chain;
  716.   real_constant_chain = r;
  717.  
  718.   /* Store const0_rtx in mem-slot since this CONST_DOUBLE is on the chain.
  719.      Actual use of mem-slot is only through force_const_double_mem.  */
  720.  
  721.   CONST_DOUBLE_MEM (r) = const0_rtx;
  722.  
  723.   return r;
  724. }
  725.  
  726. /* Return a CONST_DOUBLE for a specified `double' value
  727.    and machine mode.  */
  728.  
  729. rtx
  730. immed_real_const_1 (d, mode)
  731.      REAL_VALUE_TYPE d;
  732.      enum machine_mode mode;
  733. {
  734.   union real_extract u;
  735.   register rtx r;
  736.   REAL_VALUE_TYPE negated;
  737.  
  738.   /* Get the desired `double' value as a sequence of ints
  739.      since that is how they are stored in a CONST_DOUBLE.  */
  740.  
  741.   u.d = d;
  742.  
  743.   /* Detect zero.  */
  744.  
  745.   negated = REAL_VALUE_NEGATE (d);
  746.   if (REAL_VALUES_EQUAL (negated, d))
  747.     return (mode == DFmode ? dconst0_rtx : fconst0_rtx);
  748.  
  749.   if (sizeof u == 2 * sizeof (int))
  750.     return immed_double_const (u.i[0], u.i[1], mode);
  751.  
  752.   /* The rest of this function handles the case where
  753.      a float value requires more than 2 ints of space.
  754.      It will be deleted as dead code on machines that don't need it.  */
  755.  
  756.   /* Search the chain for an existing CONST_DOUBLE with the right value.
  757.      If one is found, return it.  */
  758.  
  759.   for (r = real_constant_chain; r; r = CONST_DOUBLE_CHAIN (r))
  760.     if (! bcmp (&CONST_DOUBLE_LOW (r), &u, sizeof u)
  761.     && GET_MODE (r) == mode)
  762.       return r;
  763.  
  764.   /* No; make a new one and add it to the chain.  */
  765.  
  766.   r = rtx_alloc (CONST_DOUBLE);
  767.   PUT_MODE (r, mode);
  768.   bcopy (&u, &CONST_DOUBLE_LOW (r), sizeof u);
  769.  
  770.   CONST_DOUBLE_CHAIN (r) = real_constant_chain;
  771.   real_constant_chain = r;
  772.  
  773.   /* Store const0_rtx in slot 2 since this CONST_DOUBLE is on the chain.
  774.      Actual use of slot 2 is only through force_const_double_mem.  */
  775.  
  776.   CONST_DOUBLE_MEM (r) = const0_rtx;
  777.  
  778.   return r;
  779. }
  780.  
  781. /* Return a CONST_DOUBLE rtx for a value specified by EXP,
  782.    which must be a REAL_CST tree node.  */
  783.  
  784. rtx
  785. immed_real_const (exp)
  786.      tree exp;
  787. {
  788.   return immed_real_const_1 (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)));
  789. }
  790.  
  791. /* Given a CONST_DOUBLE, cause a constant in memory to be created
  792.    (unless we already have one for the same value)
  793.    and return a MEM rtx to refer to it.
  794.    Put the CONST_DOUBLE on real_constant_chain if it isn't already there.  */
  795.  
  796. rtx
  797. force_const_double_mem (r)
  798.      rtx r;
  799. {
  800.   if (CONST_DOUBLE_MEM (r) == cc0_rtx)
  801.     {
  802.       CONST_DOUBLE_CHAIN (r) = real_constant_chain;
  803.       real_constant_chain = r;
  804.       CONST_DOUBLE_MEM (r) = const0_rtx;
  805.     }
  806.  
  807.   if (CONST_DOUBLE_MEM (r) == const0_rtx)
  808.     {
  809.       CONST_DOUBLE_MEM (r) = force_const_mem (GET_MODE (r), r);
  810.     }
  811.   /* CONST_DOUBLE_MEM (r) is now a MEM with a constant address.
  812.      If that is legitimate, return it.
  813.      Othewise it will need reloading, so return a copy of it.  */
  814.   if (memory_address_p (GET_MODE (r), XEXP (CONST_DOUBLE_MEM (r), 0)))
  815.     return CONST_DOUBLE_MEM (r);
  816.   return gen_rtx (MEM, GET_MODE (r), XEXP (CONST_DOUBLE_MEM (r), 0));
  817. }
  818.  
  819. /* At the end of a function, forget the memory-constants
  820.    previously made for CONST_DOUBLEs.  Mark them as not on real_constant_chain.
  821.    Also clear out real_constant_chain and clear out all the chain-pointers.  */
  822.  
  823. void
  824. clear_const_double_mem ()
  825. {
  826.   register rtx r, next;
  827.  
  828.   for (r = real_constant_chain; r; r = next)
  829.     {
  830.       next = CONST_DOUBLE_CHAIN (r);
  831.       CONST_DOUBLE_CHAIN (r) = 0;
  832.       CONST_DOUBLE_MEM (r) = cc0_rtx;
  833.     }
  834.   real_constant_chain = 0;
  835. }
  836.  
  837. /* Given an expression EXP with a constant value,
  838.    reduce it to the sum of an assembler symbol and an integer.
  839.    Store them both in the structure *VALUE.
  840.    Abort if EXP does not reduce.  */
  841.  
  842. struct addr_const
  843. {
  844.   rtx base;
  845.   int offset;
  846. };
  847.  
  848. static void
  849. decode_addr_const (exp, value)
  850.      tree exp;
  851.      struct addr_const *value;
  852. {
  853.   register tree target = TREE_OPERAND (exp, 0);
  854.   register int offset = 0;
  855.   register rtx x;
  856.  
  857.   while (1)
  858.     {
  859.       if (TREE_CODE (target) == COMPONENT_REF)
  860.     {
  861.       offset += DECL_OFFSET (TREE_OPERAND (target, 1)) / BITS_PER_UNIT;
  862.       target = TREE_OPERAND (target, 0);
  863.     }
  864.       else if (TREE_CODE (target) == ARRAY_REF)
  865.     {
  866.       if (TREE_CODE (TREE_OPERAND (target, 1)) != INTEGER_CST
  867.           || TREE_CODE (TYPE_SIZE (TREE_TYPE (target))) != INTEGER_CST)
  868.         abort ();
  869.       offset += ((TYPE_SIZE_UNIT (TREE_TYPE (target))
  870.               * TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (target)))
  871.               * TREE_INT_CST_LOW (TREE_OPERAND (target, 1)))
  872.              / BITS_PER_UNIT);
  873.       target = TREE_OPERAND (target, 0);
  874.     }
  875.       else break;
  876.     }
  877.  
  878.   if (TREE_CODE (target) == VAR_DECL
  879.       || TREE_CODE (target) == FUNCTION_DECL)
  880.     x = DECL_RTL (target);
  881.   else if (TREE_LITERAL (target))
  882.     x = TREE_CST_RTL (target);
  883.   else
  884.     abort ();
  885.  
  886.   if (GET_CODE (x) != MEM)
  887.     abort ();
  888.   x = XEXP (x, 0);
  889.  
  890.   value->base = x;
  891.   value->offset = offset;
  892. }
  893.  
  894. /* Uniquize all constants that appear in memory.
  895.    Each constant in memory thus far output is recorded
  896.    in `const_hash_table' with a `struct constant_descriptor'
  897.    that contains a polish representation of the value of
  898.    the constant.
  899.  
  900.    We cannot store the trees in the hash table
  901.    because the trees may be temporary.  */
  902.  
  903. struct constant_descriptor
  904. {
  905.   struct constant_descriptor *next;
  906.   char *label;
  907.   char contents[1];
  908. };
  909.  
  910. #define HASHBITS 30
  911. #define MAX_HASH_TABLE 1007
  912. static struct constant_descriptor *const_hash_table[MAX_HASH_TABLE];
  913.  
  914. /* Compute a hash code for a constant expression.  */
  915.  
  916. int
  917. const_hash (exp)
  918.      tree exp;
  919. {
  920.   register char *p;
  921.   register int len, hi, i;
  922.   register enum tree_code code = TREE_CODE (exp);
  923.  
  924.   if (code == INTEGER_CST)
  925.     {
  926.       p = (char *) &TREE_INT_CST_LOW (exp);
  927.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  928.     }
  929.   else if (code == REAL_CST)
  930.     {
  931.       p = (char *) &TREE_REAL_CST (exp);
  932.       len = sizeof TREE_REAL_CST (exp);
  933.     }
  934.   else if (code == STRING_CST)
  935.     p = TREE_STRING_POINTER (exp), len = TREE_STRING_LENGTH (exp);
  936.   else if (code == COMPLEX_CST)
  937.     return const_hash (TREE_REALPART (exp)) * 5
  938.       + const_hash (TREE_IMAGPART (exp));
  939.   else if (code == CONSTRUCTOR)
  940.     {
  941.       register tree link;
  942.  
  943.       /* For record type, include the type in the hashing.
  944.      We do not do so for array types
  945.      because (1) the sizes of the elements are sufficient
  946.      and (2) distinct array types can have the same constructor.  */
  947.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  948.     hi = ((int) TREE_TYPE (exp) & ((1 << HASHBITS) - 1)) % MAX_HASH_TABLE;
  949.       else
  950.     hi = 5;
  951.  
  952.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  953.     hi = (hi * 603 + const_hash (TREE_VALUE (link))) % MAX_HASH_TABLE;
  954.  
  955.       return hi;
  956.     }
  957.   else if (code == ADDR_EXPR)
  958.     {
  959.       struct addr_const value;
  960.       decode_addr_const (exp, &value);
  961.       p = (char *) &value;
  962.       len = sizeof value;
  963.     }
  964.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  965.     return const_hash (TREE_OPERAND (exp, 0)) * 9
  966.       +  const_hash (TREE_OPERAND (exp, 1));
  967.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  968.     return const_hash (TREE_OPERAND (exp, 0)) * 7 + 2;
  969.  
  970.   /* Compute hashing function */
  971.   hi = len;
  972.   for (i = 0; i < len; i++)
  973.     hi = ((hi * 613) + (unsigned)(p[i]));
  974.  
  975.   hi &= (1 << HASHBITS) - 1;
  976.   hi %= MAX_HASH_TABLE;
  977.   return hi;
  978. }
  979.  
  980. /* Compare a constant expression EXP with a constant-descriptor DESC.
  981.    Return 1 if DESC describes a constant with the same value as EXP.  */
  982.  
  983. static int
  984. compare_constant (exp, desc)
  985.      tree exp;
  986.      struct constant_descriptor *desc;
  987. {
  988.   return 0 != compare_constant_1 (exp, desc->contents);
  989. }
  990.  
  991. /* Compare constant expression EXP with a substring P of a constant descriptor.
  992.    If they match, return a pointer to the end of the substring matched.
  993.    If they do not match, return 0.
  994.  
  995.    Since descriptors are written in polish prefix notation,
  996.    this function can be used recursively to test one operand of EXP
  997.    against a subdescriptor, and if it succeeds it returns the
  998.    address of the subdescriptor for the next operand.  */
  999.  
  1000. static char *
  1001. compare_constant_1 (exp, p)
  1002.      tree exp;
  1003.      char *p;
  1004. {
  1005.   register char *strp;
  1006.   register int len;
  1007.   register enum tree_code code = TREE_CODE (exp);
  1008.  
  1009.   if (code != (enum tree_code) *p++)
  1010.     return 0;
  1011.  
  1012.   if (code == INTEGER_CST)
  1013.     {
  1014.       /* Integer constants are the same only if the same width of type.  */
  1015.       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
  1016.     return 0;
  1017.       strp = (char *) &TREE_INT_CST_LOW (exp);
  1018.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  1019.     }
  1020.   else if (code == REAL_CST)
  1021.     {
  1022.       /* Real constants are the same only if the same width of type.  */
  1023.       if (*p++ != TYPE_PRECISION (TREE_TYPE (exp)))
  1024.     return 0;
  1025.       strp = (char *) &TREE_REAL_CST (exp);
  1026.       len = sizeof TREE_REAL_CST (exp);
  1027.     }
  1028.   else if (code == STRING_CST)
  1029.     {
  1030.       if (flag_writable_strings)
  1031.     return 0;
  1032.       strp = TREE_STRING_POINTER (exp);
  1033.       len = TREE_STRING_LENGTH (exp);
  1034.       if (bcmp (&TREE_STRING_LENGTH (exp), p,
  1035.         sizeof TREE_STRING_LENGTH (exp)))
  1036.     return 0;
  1037.       p += sizeof TREE_STRING_LENGTH (exp);
  1038.     }
  1039.   else if (code == COMPLEX_CST)
  1040.     {
  1041.       p = compare_constant_1 (TREE_REALPART (exp), p);
  1042.       if (p == 0) return 0;
  1043.       p = compare_constant_1 (TREE_IMAGPART (exp), p);
  1044.       return p;
  1045.     }
  1046.   else if (code == CONSTRUCTOR)
  1047.     {
  1048.       register tree link;
  1049.       int length = list_length (CONSTRUCTOR_ELTS (exp));
  1050.       tree type;
  1051.  
  1052.       if (bcmp (&length, p, sizeof length))
  1053.     return 0;
  1054.       p += sizeof length;
  1055.  
  1056.       /* For record constructors, insist that the types match.
  1057.      For arrays, just verify both constructors are for arrays.  */
  1058.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  1059.     type = TREE_TYPE (exp);
  1060.       else
  1061.     type = 0;
  1062.       if (bcmp (&type, p, sizeof type))
  1063.     return 0;
  1064.       p += sizeof type;
  1065.  
  1066.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  1067.     if ((p = compare_constant_1 (TREE_VALUE (link), p)) == 0)
  1068.       return 0;
  1069.       return p;
  1070.     }
  1071.   else if (code == ADDR_EXPR)
  1072.     {
  1073.       struct addr_const value;
  1074.       decode_addr_const (exp, &value);
  1075.       strp = (char *) &value;
  1076.       len = sizeof value;
  1077.       /* Compare SYMBOL_REF address and offset.  */
  1078.       while (--len >= 0)
  1079.     if (*p++ != *strp++)
  1080.       return 0;
  1081.       /* Compare symbol name.  */
  1082.       strp = XSTR (value.base, 0);
  1083.       len = strlen (strp) + 1;
  1084.     }
  1085.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  1086.     {
  1087.       if (*p++ != (char) code)
  1088.     return 0;
  1089.       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
  1090.       if (p == 0) return 0;
  1091.       p = compare_constant_1 (TREE_OPERAND (exp, 1), p);
  1092.       return p;
  1093.     }
  1094.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  1095.     {
  1096.       if (*p++ != (char) code)
  1097.     return 0;
  1098.       p = compare_constant_1 (TREE_OPERAND (exp, 0), p);
  1099.       return p;
  1100.     }
  1101.  
  1102.   /* Compare constant contents.  */
  1103.   while (--len >= 0)
  1104.     if (*p++ != *strp++)
  1105.       return 0;
  1106.  
  1107.   return p;
  1108. }
  1109.  
  1110. /* Construct a constant descriptor for the expression EXP.
  1111.    It is up to the caller to enter the descriptor in the hash table.  */
  1112.  
  1113. static struct constant_descriptor *
  1114. record_constant (exp)
  1115.      tree exp;
  1116. {
  1117.   struct constant_descriptor *ptr = 0;
  1118.   int buf;
  1119.  
  1120.   obstack_grow (&permanent_obstack, &ptr, sizeof ptr);
  1121.   obstack_grow (&permanent_obstack, &buf, sizeof buf);
  1122.   record_constant_1 (exp);
  1123.   return (struct constant_descriptor *) obstack_finish (&permanent_obstack);
  1124. }
  1125.  
  1126. /* Add a description of constant expression EXP
  1127.    to the object growing in `permanent_obstack'.
  1128.    No need to return its address; the caller will get that
  1129.    from the obstack when the object is complete.  */
  1130.  
  1131. static void
  1132. record_constant_1 (exp)
  1133.      tree exp;
  1134. {
  1135.   register char *strp;
  1136.   register int len;
  1137.   register enum tree_code code = TREE_CODE (exp);
  1138.  
  1139.   obstack_1grow (&permanent_obstack, (unsigned int) code);
  1140.  
  1141.   if (code == INTEGER_CST)
  1142.     {
  1143.       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
  1144.       strp = (char *) &TREE_INT_CST_LOW (exp);
  1145.       len = 2 * sizeof TREE_INT_CST_LOW (exp);
  1146.     }
  1147.   else if (code == REAL_CST)
  1148.     {
  1149.       obstack_1grow (&permanent_obstack, TYPE_PRECISION (TREE_TYPE (exp)));
  1150.       strp = (char *) &TREE_REAL_CST (exp);
  1151.       len = sizeof TREE_REAL_CST (exp);
  1152.     }
  1153.   else if (code == STRING_CST)
  1154.     {
  1155.       if (flag_writable_strings)
  1156.     return;
  1157.       strp = TREE_STRING_POINTER (exp);
  1158.       len = TREE_STRING_LENGTH (exp);
  1159.       obstack_grow (&permanent_obstack, (char *) &TREE_STRING_LENGTH (exp),
  1160.             sizeof TREE_STRING_LENGTH (exp));
  1161.     }
  1162.   else if (code == COMPLEX_CST)
  1163.     {
  1164.       record_constant_1 (TREE_REALPART (exp));
  1165.       record_constant_1 (TREE_IMAGPART (exp));
  1166.       return;
  1167.     }
  1168.   else if (code == CONSTRUCTOR)
  1169.     {
  1170.       register tree link;
  1171.       int length = list_length (CONSTRUCTOR_ELTS (exp));
  1172.       tree type;
  1173.  
  1174.       obstack_grow (&permanent_obstack, (char *) &length, sizeof length);
  1175.  
  1176.       /* For record constructors, insist that the types match.
  1177.      For arrays, just verify both constructors are for arrays.  */
  1178.       if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
  1179.     type = TREE_TYPE (exp);
  1180.       else
  1181.     type = 0;
  1182.       obstack_grow (&permanent_obstack, (char *) &type, sizeof type);
  1183.  
  1184.       for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  1185.     record_constant_1 (TREE_VALUE (link));
  1186.       return;
  1187.     }
  1188.   else if (code == ADDR_EXPR)
  1189.     {
  1190.       struct addr_const value;
  1191.       decode_addr_const (exp, &value);
  1192.       /* Record the SYMBOL_REF address and the offset.  */
  1193.       obstack_grow (&permanent_obstack, (char *) &value, sizeof value);
  1194.       /* Record the symbol name.  */
  1195.       obstack_grow (&permanent_obstack, XSTR (value.base, 0),
  1196.             strlen (XSTR (value.base, 0)) + 1);
  1197.       return;
  1198.     }
  1199.   else if (code == PLUS_EXPR || code == MINUS_EXPR)
  1200.     {
  1201.       obstack_1grow (&permanent_obstack, (int) code);
  1202.       record_constant_1 (TREE_OPERAND (exp, 0));
  1203.       record_constant_1 (TREE_OPERAND (exp, 1));
  1204.       return;
  1205.     }
  1206.   else if (code == NOP_EXPR || code == CONVERT_EXPR)
  1207.     {
  1208.       obstack_1grow (&permanent_obstack, (int) code);
  1209.       record_constant_1 (TREE_OPERAND (exp, 0));
  1210.       return;
  1211.     }
  1212.  
  1213.   /* Record constant contents.  */
  1214.   obstack_grow (&permanent_obstack, strp, len);
  1215. }
  1216.  
  1217. /* Return the constant-label-string for constant value EXP.
  1218.    If no constant equal to EXP has yet been output,
  1219.    define a new label and output assembler code for it.
  1220.    The const_hash_table records which constants already have label strings.  */
  1221.  
  1222. static char *
  1223. get_or_assign_label (exp)
  1224.      tree exp;
  1225. {
  1226.   register int hash, i, align;
  1227.   register struct constant_descriptor *desc;
  1228.   char label[256];
  1229.  
  1230.   /* Make sure any other constants whose addresses appear in EXP
  1231.      are assigned label numbers.  */
  1232.  
  1233.   output_addressed_constants (exp);
  1234.  
  1235.   /* Compute hash code of EXP.  Search the descriptors for that hash code
  1236.      to see if any of them describes EXP.  If yes, the descriptor records
  1237.      the label number already assigned.  */
  1238.  
  1239.   hash = const_hash (exp) % MAX_HASH_TABLE;
  1240.  
  1241.   for (desc = const_hash_table[hash]; desc; desc = desc->next)
  1242.     if (compare_constant (exp, desc))
  1243.       return desc->label;
  1244.  
  1245.   /* No constant equal to EXP is known to have been output.
  1246.      Make a constant descriptor to enter EXP in the hash table.
  1247.      Assign the label number and record it in the descriptor for
  1248.      future calls to this function to find.  */
  1249.  
  1250.   desc = record_constant (exp);
  1251.   desc->next = const_hash_table[hash];
  1252.   const_hash_table[hash] = desc;
  1253.  
  1254.   /* Now output assembler code to define that label
  1255.      and follow it with the data of EXP.  */
  1256.  
  1257.   /* First switch to text section, except for writable strings.  */
  1258. #ifdef SELECT_SECTION
  1259.   SELECT_SECTION (exp);
  1260. #else
  1261.   if ((TREE_CODE (exp) == STRING_CST) && flag_writable_strings)
  1262.     data_section ();
  1263.   else
  1264.     text_section ();
  1265. #endif
  1266.  
  1267.   /* Align the location counter as required by EXP's data type.  */
  1268. #ifdef CONSTANT_ALIGNMENT
  1269.   align = CONSTANT_ALIGNMENT (TREE_CODE (exp), TYPE_ALIGN (TREE_TYPE (exp)));
  1270. #else
  1271.   align = TYPE_ALIGN (TREE_TYPE (exp));
  1272. #endif
  1273.  
  1274.   for (i = 0; align >= BITS_PER_UNIT << (i + 1); i++);
  1275.   if (i > 0)
  1276.     ASM_OUTPUT_ALIGN (asm_out_file, i);
  1277.  
  1278.   /* Output the label itself.  */
  1279.   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno);
  1280.  
  1281.   /* Output the value of EXP.  */
  1282.   output_constant (exp,
  1283.            (TREE_CODE (exp) == STRING_CST
  1284.             ? TREE_STRING_LENGTH (exp)
  1285.             : int_size_in_bytes (TREE_TYPE (exp))));
  1286.  
  1287.   /* Create a string containing the label name, in LABEL.  */
  1288.   ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
  1289.  
  1290.   ++const_labelno;
  1291.  
  1292.   desc->label
  1293.     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
  1294.  
  1295.   return desc->label;
  1296. }
  1297.  
  1298. /* Return an rtx representing a reference to constant data in memory
  1299.    for the constant expression EXP.
  1300.    If assembler code for such a constant has already been output,
  1301.    return an rtx to refer to it.
  1302.    Otherwise, output such a constant in memory and generate
  1303.    an rtx for it.  The TREE_CST_RTL of EXP is set up to point to that rtx.  */
  1304.  
  1305. rtx
  1306. output_constant_def (exp)
  1307.      tree exp;
  1308. {
  1309.   register rtx def;
  1310.   int temp_p = allocation_temporary_p ();
  1311.  
  1312.   if (TREE_CODE (exp) == INTEGER_CST)
  1313.     abort ();            /* No TREE_CST_RTL slot in these.  */
  1314.  
  1315.   if (TREE_CST_RTL (exp))
  1316.     return TREE_CST_RTL (exp);
  1317.  
  1318.   if (TREE_PERMANENT (exp))
  1319.     end_temporary_allocation ();
  1320.  
  1321.   def = gen_rtx (SYMBOL_REF, Pmode, get_or_assign_label (exp));
  1322.  
  1323.   TREE_CST_RTL (exp)
  1324.     = gen_rtx (MEM, TYPE_MODE (TREE_TYPE (exp)), def);
  1325.   RTX_UNCHANGING_P (TREE_CST_RTL (exp)) = 1;
  1326.  
  1327.   if (temp_p && TREE_PERMANENT (exp))
  1328.     resume_temporary_allocation ();
  1329.  
  1330.   return TREE_CST_RTL (exp);
  1331. }
  1332.  
  1333. /* Similar hash facility for making memory-constants
  1334.    from constant rtl-expressions.  It is used on RISC machines
  1335.    where immediate integer arguments and constant addresses are restricted
  1336.    so that such constants must be stored in memory.
  1337.  
  1338.    This pool of constants is reinitialized for each function
  1339.    so each function gets its own constants-pool that comes right before it.  */
  1340.  
  1341. #define MAX_RTX_HASH_TABLE 61
  1342. static struct constant_descriptor *const_rtx_hash_table[MAX_RTX_HASH_TABLE];
  1343.  
  1344. void
  1345. init_const_rtx_hash_table ()
  1346. {
  1347.   bzero (const_rtx_hash_table, sizeof const_rtx_hash_table);
  1348. }
  1349.  
  1350. struct rtx_const
  1351. {
  1352. #if defined ( _MSDOS )
  1353.   enum kind { RTX_DOUBLE, RTX_INT } kind;
  1354.   enum machine_mode mode;
  1355. #else
  1356.   enum kind { RTX_DOUBLE, RTX_INT } kind : 16;
  1357.   enum machine_mode mode : 16;
  1358. #endif
  1359.   union {
  1360.     union real_extract du;
  1361.     struct addr_const addr;
  1362.   } un;
  1363. };
  1364.  
  1365. /* Express an rtx for a constant integer (perhaps symbolic)
  1366.    as the sum of a symbol or label plus an explicit integer.
  1367.    They are stored into VALUE.  */
  1368.  
  1369. static void
  1370. decode_rtx_const (mode, x, value)
  1371.      enum machine_mode mode;
  1372.      rtx x;
  1373.      struct rtx_const *value;
  1374. {
  1375.   /* Clear the whole structure, including any gaps.  */
  1376.  
  1377.   {
  1378.     int *p = (int *) value;
  1379.     int *end = (int *) (value + 1);
  1380.     while (p < end)
  1381.       *p++ = 0;
  1382.   }
  1383.  
  1384.   value->kind = RTX_INT;    /* Most usual kind. */
  1385.   value->mode = mode;
  1386.  
  1387.   switch (GET_CODE (x))
  1388.     {
  1389.     case CONST_DOUBLE:
  1390.       value->kind = RTX_DOUBLE;
  1391.       value->mode = GET_MODE (x);
  1392.       bcopy (&CONST_DOUBLE_LOW (x), &value->un.du, sizeof value->un.du);
  1393.       break;
  1394.  
  1395.     case CONST_INT:
  1396.       value->un.addr.offset = INTVAL (x);
  1397.       break;
  1398.  
  1399.     case SYMBOL_REF:
  1400.       value->un.addr.base = x;
  1401.       break;
  1402.  
  1403.     case LABEL_REF:
  1404.       value->un.addr.base = x;
  1405.       break;
  1406.  
  1407.     case CONST:
  1408.       x = XEXP (x, 0);
  1409.       if (GET_CODE (x) == PLUS)
  1410.     {
  1411.       value->un.addr.base = XEXP (XEXP (x, 0), 0);
  1412.       if (GET_CODE (XEXP (x, 1)) != CONST_INT)
  1413.         abort ();
  1414.       value->un.addr.offset = INTVAL (XEXP (x, 1));
  1415.     }
  1416.       else if (GET_CODE (x) == MINUS)
  1417.     {
  1418.       value->un.addr.base = XEXP (x, 0);
  1419.       if (GET_CODE (XEXP (x, 1)) != CONST_INT)
  1420.         abort ();
  1421.       value->un.addr.offset = - INTVAL (XEXP (x, 1));
  1422.     }
  1423.       else
  1424.     abort ();
  1425.       break;
  1426.  
  1427.     default:
  1428.       abort ();
  1429.     }
  1430.  
  1431.   if (value->kind == RTX_INT && value->un.addr.base != 0)
  1432.     switch (GET_CODE (value->un.addr.base))
  1433.       {
  1434.       case SYMBOL_REF:
  1435.       case LABEL_REF:
  1436.     /* Use the string's address, not the SYMBOL_REF's address,
  1437.        for the sake of addresses of library routines.
  1438.        For a LABEL_REF, compare labels.  */
  1439.     value->un.addr.base = XEXP (value->un.addr.base, 0);
  1440.       }
  1441. }
  1442.  
  1443. /* Compute a hash code for a constant RTL expression.  */
  1444.  
  1445. int
  1446. const_hash_rtx (mode, x)
  1447.      enum machine_mode mode;
  1448.      rtx x;
  1449. {
  1450.   register int hi, i;
  1451.  
  1452.   struct rtx_const value;
  1453.   decode_rtx_const (mode, x, &value);
  1454.  
  1455.   /* Compute hashing function */
  1456.   hi = 0;
  1457.   for (i = 0; i < sizeof value / sizeof (int); i++)
  1458.     hi += ((int *) &value)[i];
  1459.  
  1460.   hi &= (1 << HASHBITS) - 1;
  1461.   hi %= MAX_RTX_HASH_TABLE;
  1462.   return hi;
  1463. }
  1464.  
  1465. /* Compare a constant rtl object X with a constant-descriptor DESC.
  1466.    Return 1 if DESC describes a constant with the same value as X.  */
  1467.  
  1468. static int
  1469. compare_constant_rtx (mode, x, desc)
  1470.      enum machine_mode mode;
  1471.      rtx x;
  1472.      struct constant_descriptor *desc;
  1473. {
  1474.   register int *p = (int *) desc->contents;
  1475.   register int *strp;
  1476.   register int len;
  1477.   struct rtx_const value;
  1478.  
  1479.   decode_rtx_const (mode, x, &value);
  1480.   strp = (int *) &value;
  1481.   len = sizeof value / sizeof (int);
  1482.  
  1483.   /* Compare constant contents.  */
  1484.   while (--len >= 0)
  1485.     if (*p++ != *strp++)
  1486.       return 0;
  1487.  
  1488.   return 1;
  1489. }
  1490.  
  1491. /* Construct a constant descriptor for the rtl-expression X.
  1492.    It is up to the caller to enter the descriptor in the hash table.  */
  1493.  
  1494. static struct constant_descriptor *
  1495. record_constant_rtx (mode, x)
  1496.      enum machine_mode mode;
  1497.      rtx x;
  1498. {
  1499.   struct constant_descriptor *ptr = 0;
  1500.   int buf;
  1501.   struct rtx_const value;
  1502.  
  1503.   decode_rtx_const (mode, x, &value);
  1504.  
  1505.   obstack_grow (saveable_obstack, &ptr, sizeof ptr);
  1506.   obstack_grow (saveable_obstack, &buf, sizeof buf);
  1507.  
  1508.   /* Record constant contents.  */
  1509.   obstack_grow (saveable_obstack, &value, sizeof value);
  1510.  
  1511.   return (struct constant_descriptor *) obstack_finish (saveable_obstack);
  1512. }
  1513.  
  1514. /* Given a constant rtx X, make (or find) a memory constant for its value
  1515.    and return a MEM rtx to refer to it in memory.  */
  1516.  
  1517. rtx
  1518. force_const_mem (mode, x)
  1519.      enum machine_mode mode;
  1520.      rtx x;
  1521. {
  1522.   register int hash;
  1523.   register struct constant_descriptor *desc;
  1524.   char label[256];
  1525.   char *found = 0;
  1526.   rtx def;
  1527.  
  1528.   if (GET_CODE (x) == CONST_DOUBLE
  1529.       && GET_CODE (CONST_DOUBLE_MEM (x)) == MEM)
  1530.     return CONST_DOUBLE_MEM (x);
  1531.  
  1532. #if defined( DSP96000 )
  1533.   if ( mode == DImode )
  1534.   {
  1535.       /* we only use DImode to represent the 64bit register output of a mpy.
  1536.      we never care about the MSW - the DImode trick is used to tell the
  1537.      compiler that a register has been clobbered. Thus, we don't really
  1538.      implement DImode. DImode constants found here are really constant
  1539.      folded mult output. Force the mode to SImode, which it really is 
  1540.      anyway. */
  1541.  
  1542.       mode = SImode;
  1543.   }
  1544. #endif  
  1545.   /* Compute hash code of X.  Search the descriptors for that hash code
  1546.      to see if any of them describes X.  If yes, the descriptor records
  1547.      the label number already assigned.  */
  1548.  
  1549.   hash = const_hash_rtx (mode, x);
  1550.  
  1551.   for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
  1552.     if (compare_constant_rtx (mode, x, desc))
  1553.       {
  1554.     found = desc->label;
  1555.     break;
  1556.       }
  1557.  
  1558.   if (found == 0)
  1559.     {
  1560.       int align;
  1561.  
  1562.       /* No constant equal to X is known to have been output.
  1563.      Make a constant descriptor to enter X in the hash table.
  1564.      Assign the label number and record it in the descriptor for
  1565.      future calls to this function to find.  */
  1566.  
  1567.       desc = record_constant_rtx (mode, x);
  1568.       desc->next = const_rtx_hash_table[hash];
  1569.       const_rtx_hash_table[hash] = desc;
  1570.  
  1571.       /* Now output assembler code to define that label
  1572.      and follow it with the data of EXP.  */
  1573.  
  1574.       /* First switch to text section.  */
  1575. #ifdef SELECT_RTX_SECTION
  1576.       SELECT_RTX_SECTION (mode, x);
  1577. #else
  1578.       text_section ();
  1579. #endif
  1580.  
  1581.       /* Align the location counter as required by EXP's data type.  */
  1582.       align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
  1583.       if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  1584.     align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
  1585.  
  1586.       if (align > 1)
  1587.     ASM_OUTPUT_ALIGN (asm_out_file, exact_log2 (align));
  1588.  
  1589.       /* Output the label itself.  */
  1590.       ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LC", const_labelno);
  1591.  
  1592.       /* Output the value of EXP.  */
  1593.       if (GET_CODE (x) == CONST_DOUBLE)
  1594.     {
  1595.       union real_extract u;
  1596.  
  1597.       bcopy (&CONST_DOUBLE_LOW (x), &u, sizeof u);
  1598.       switch (mode)
  1599.         {
  1600.           /* Perhaps change the following to use
  1601.          CONST_DOUBLE_LOW and CONST_DOUBLE_HIGH, rather than u.i.  */
  1602.         case DImode:
  1603. #ifdef ASM_OUTPUT_DOUBLE_INT
  1604.           ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
  1605. #else /* no ASM_OUTPUT_DOUBLE_INT */
  1606. #ifndef WORDS_BIG_ENDIAN
  1607.           /* Output two ints.  */
  1608.           ASM_OUTPUT_INT (asm_out_file,
  1609.                   gen_rtx (CONST_INT, VOIDmode, u.i[0]));
  1610.           ASM_OUTPUT_INT (asm_out_file,
  1611.                   gen_rtx (CONST_INT, VOIDmode, u.i[1]));
  1612. #else
  1613.           /* Output two ints.  */
  1614.           ASM_OUTPUT_INT (asm_out_file,
  1615.                   gen_rtx (CONST_INT, VOIDmode, u.i[1]));
  1616.           ASM_OUTPUT_INT (asm_out_file,
  1617.                   gen_rtx (CONST_INT, VOIDmode, u.i[0]));
  1618. #endif /* WORDS_BIG_ENDIAN */
  1619. #endif /* no ASM_OUTPUT_DOUBLE_INT */
  1620.           break;
  1621.  
  1622.         case DFmode:
  1623.           ASM_OUTPUT_DOUBLE (asm_out_file, u.d);
  1624.           break;
  1625.  
  1626.         case SFmode:
  1627.           ASM_OUTPUT_FLOAT (asm_out_file, u.d);
  1628.         }
  1629.     }
  1630.       else
  1631.     switch (mode)
  1632.       {
  1633.       case SImode:
  1634.         ASM_OUTPUT_INT (asm_out_file, x);
  1635.         break;
  1636.  
  1637.       case HImode:
  1638.         ASM_OUTPUT_SHORT (asm_out_file, x);
  1639.         break;
  1640.  
  1641.       case QImode:
  1642.         ASM_OUTPUT_CHAR (asm_out_file, x);
  1643.         break;
  1644.       }
  1645.  
  1646.       /* Create a string containing the label name, in LABEL.  */
  1647.       ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
  1648.  
  1649.       ++const_labelno;
  1650.  
  1651.       desc->label = found
  1652.     = (char *) obstack_copy0 (&permanent_obstack, label, strlen (label));
  1653.     }
  1654.  
  1655.   /* We have a symbol name; construct the SYMBOL_REF and the MEM.  */
  1656.  
  1657.   def = gen_rtx (MEM, mode, gen_rtx (SYMBOL_REF, Pmode, desc->label));
  1658.  
  1659.   RTX_UNCHANGING_P (def) = 1;
  1660.   /* Mark the symbol_ref as belonging to this constants pool.  */
  1661.   CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
  1662.  
  1663.   if (GET_CODE (x) == CONST_DOUBLE)
  1664.     {
  1665.       if (CONST_DOUBLE_MEM (x) == cc0_rtx)
  1666.     {
  1667.       CONST_DOUBLE_CHAIN (x) = real_constant_chain;
  1668.       real_constant_chain = x;
  1669.     }
  1670.       CONST_DOUBLE_MEM (x) = def;
  1671.     }
  1672.  
  1673.   return def;
  1674. }
  1675.  
  1676. /* Find all the constants whose addresses are referenced inside of EXP,
  1677.    and make sure assembler code with a label has been output for each one.  */
  1678.  
  1679. void
  1680. output_addressed_constants (exp)
  1681.      tree exp;
  1682. {
  1683.   switch (TREE_CODE (exp))
  1684.     {
  1685.     case ADDR_EXPR:
  1686.       {
  1687.     register tree constant = TREE_OPERAND (exp, 0);
  1688.  
  1689.     while (TREE_CODE (constant) == COMPONENT_REF)
  1690.       {
  1691.         constant = TREE_OPERAND (constant, 0);
  1692.       }
  1693.  
  1694.     if (TREE_LITERAL (constant))
  1695.       /* No need to do anything here
  1696.          for addresses of variables or functions.  */
  1697.       output_constant_def (constant);
  1698.       }
  1699.       break;
  1700.  
  1701.     case PLUS_EXPR:
  1702.     case MINUS_EXPR:
  1703.       output_addressed_constants (TREE_OPERAND (exp, 0));
  1704.       output_addressed_constants (TREE_OPERAND (exp, 1));
  1705.       break;
  1706.  
  1707.     case NOP_EXPR:
  1708.     case CONVERT_EXPR:
  1709.       output_addressed_constants (TREE_OPERAND (exp, 0));
  1710.       break;
  1711.  
  1712.     case CONSTRUCTOR:
  1713.       {
  1714.     register tree link;
  1715.     for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
  1716.       output_addressed_constants (TREE_VALUE (link));
  1717.       }
  1718.       break;
  1719.  
  1720.     case ERROR_MARK:
  1721.       break;
  1722.  
  1723.     default:
  1724.       if (! TREE_LITERAL (exp))
  1725.     abort ();
  1726.     }
  1727. }
  1728.  
  1729. /* Output assembler code for constant EXP to FILE, with no label.
  1730.    This includes the pseudo-op such as ".int" or ".byte", and a newline.
  1731.    Assumes output_addressed_constants has been done on EXP already.
  1732.  
  1733.    Generate exactly SIZE bytes of assembler data, padding at the end
  1734.    with zeros if necessary.  SIZE must always be specified.
  1735.  
  1736.    SIZE is important for structure constructors,
  1737.    since trailing members may have been omitted from the constructor.
  1738.    It is also important for initialization of arrays from string constants
  1739.    since the full length of the string constant might not be wanted.
  1740.    It is also needed for initialization of unions, where the initializer's
  1741.    type is just one member, and that may not be as long as the union.
  1742.  
  1743.    There a case in which we would fail to output exactly SIZE bytes:
  1744.    for a structure constructor that wants to produce more than SIZE bytes.
  1745.    But such constructors will never be generated for any possible input.  */
  1746.  
  1747. void
  1748. output_constant (exp, size)
  1749.      register tree exp;
  1750.      register int size;
  1751. {
  1752.   register enum tree_code code = TREE_CODE (TREE_TYPE (exp));
  1753.   rtx x;
  1754.  
  1755.   if (size == 0)
  1756.     return;
  1757.  
  1758.   /* Eliminate the NOP_EXPR that makes a cast not be an lvalue.
  1759.      That way we get the constant (we hope) inside it.  */
  1760.   if (TREE_CODE (exp) == NOP_EXPR
  1761.       && TREE_TYPE (exp) == TREE_TYPE (TREE_OPERAND (exp, 0)))
  1762.     exp = TREE_OPERAND (exp, 0);
  1763.  
  1764.   switch (code)
  1765.     {
  1766.     case INTEGER_TYPE:
  1767.     case ENUMERAL_TYPE:
  1768.     case POINTER_TYPE:
  1769.     case REFERENCE_TYPE:
  1770.       /* ??? What about       (int)((float)(int)&foo + 4)    */
  1771.       while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR)
  1772.     exp = TREE_OPERAND (exp, 0);
  1773.  
  1774. #ifndef ASM_OUTPUT_DOUBLE_INT
  1775.       if (TYPE_MODE (TREE_TYPE (exp)) == DImode)
  1776.     {
  1777.       if (TREE_CODE (exp) == INTEGER_CST)
  1778.         {
  1779. #ifndef WORDS_BIG_ENDIAN
  1780.           ASM_OUTPUT_INT (asm_out_file,
  1781.                   gen_rtx (CONST_INT, VOIDmode,
  1782.                        TREE_INT_CST_LOW (exp)));
  1783.           ASM_OUTPUT_INT (asm_out_file,
  1784.                   gen_rtx (CONST_INT, VOIDmode,
  1785.                        TREE_INT_CST_HIGH (exp)));
  1786. #else
  1787.           ASM_OUTPUT_INT (asm_out_file,
  1788.                   gen_rtx (CONST_INT, VOIDmode,
  1789.                        TREE_INT_CST_HIGH (exp)));
  1790.           ASM_OUTPUT_INT (asm_out_file,
  1791.                   gen_rtx (CONST_INT, VOIDmode,
  1792.                        TREE_INT_CST_LOW (exp)));
  1793. #endif
  1794.           size -= 8;
  1795.           break;
  1796.         }
  1797.       else
  1798.         error ("8-byte integer constant expression too complicated");
  1799.  
  1800.       break;
  1801.     }
  1802. #endif /* no ASM_OUTPUT_DOUBLE_INT */
  1803.  
  1804.       x = expand_expr (exp, 0, VOIDmode, EXPAND_SUM);
  1805.  
  1806. #if defined( DSP56000 )
  1807.       /* it's really tough (impossible) to print out integers based on size
  1808.      when we're using the 'l' memory_model. So, we print out all integer
  1809.      constant as big as we need to, and the assembler selects the right
  1810.      data size based on the latest org directive. */
  1811.  
  1812.       if ( 'l' == memory_model )
  1813.       {
  1814.       if (( CONST_INT == GET_CODE ( x )) ||
  1815.           ( CONST_DOUBLE == GET_CODE ( x )))
  1816.       {
  1817.           ASM_OUTPUT_DOUBLE_INT ( asm_out_file, x );
  1818.       }
  1819.       else
  1820.       {
  1821.           /* it must be an address constant. */
  1822.           ASM_OUTPUT_CHAR ( asm_out_file, x );
  1823.       }
  1824.       size -= 1;
  1825.       }
  1826.       else /* use size to diferentiate between long/int. */
  1827.       {
  1828.       if ( 1 == size )
  1829.       {
  1830.           /* int */
  1831.           ASM_OUTPUT_CHAR ( asm_out_file, x );
  1832.           size -= 1;
  1833.       }
  1834.       else if ( 2 == size )
  1835.       {
  1836.           /* long */
  1837.           ASM_OUTPUT_DOUBLE_INT ( asm_out_file, x );
  1838.           size -= 2;
  1839.       }
  1840.       else 
  1841.       {
  1842.           /* fubar! */
  1843.           abort ( );
  1844.       }
  1845.       }
  1846. #else
  1847.       if (size == 1)
  1848.     {
  1849.       ASM_OUTPUT_CHAR (asm_out_file, x);
  1850.       size -= 1;
  1851.     }
  1852.       else if (size == 2)
  1853.     {
  1854.       ASM_OUTPUT_SHORT (asm_out_file, x);
  1855.       size -= 2;
  1856.     }
  1857.       else if (size == 4)
  1858.     {
  1859.       ASM_OUTPUT_INT (asm_out_file, x);
  1860.       size -= 4;
  1861.     }
  1862. #ifdef ASM_OUTPUT_DOUBLE_INT
  1863.       else if (size == 8)
  1864.     {
  1865.       ASM_OUTPUT_DOUBLE_INT (asm_out_file, x);
  1866.       size -= 8;
  1867.     }
  1868. #endif /* ASM_OUTPUT_DOUBLE_INT */
  1869.       else
  1870.     abort ();
  1871. #endif /* DSP56000 */
  1872.  
  1873.       break;
  1874.  
  1875.     case REAL_TYPE:
  1876.       if (TREE_CODE (exp) != REAL_CST)
  1877.     error ("initializer for floating value is not a floating constant");
  1878.       else
  1879.     {
  1880.       REAL_VALUE_TYPE d;
  1881.       jmp_buf output_constant_handler;
  1882.  
  1883.       d = TREE_REAL_CST (exp);
  1884.       if (setjmp (output_constant_handler))
  1885.         {
  1886.           error ("floating point trap outputting a constant");
  1887. #ifdef REAL_IS_NOT_DOUBLE
  1888.           bzero (&d, sizeof d);
  1889.           d = REAL_VALUE_ATOF ("0");
  1890. #else
  1891.           d = 0;
  1892. #endif
  1893.         }
  1894.       set_float_handler (output_constant_handler);
  1895.  
  1896. # if ! defined( DSP96000 ) && ! defined( DSP56000 )
  1897.       if (size < 4)
  1898.         break;
  1899.       else if (size < 8)
  1900.         {
  1901.           ASM_OUTPUT_FLOAT (asm_out_file, d);
  1902.           size -= 4;
  1903.         }
  1904.       else
  1905.         {
  1906.           ASM_OUTPUT_DOUBLE (asm_out_file, d);
  1907.           size -= 8;
  1908.         }
  1909. # else
  1910. #if defined( DSP96000 ) || defined( DSP56000 )
  1911.       /* really doesn't matter for the 56k, but we wanna be consistent. */
  1912.       if ( double_type_node != TREE_TYPE ( exp ))
  1913. #else
  1914.       if ( size == 1 )
  1915. #endif
  1916.           ASM_OUTPUT_FLOAT (asm_out_file, d);
  1917.       else
  1918.           ASM_OUTPUT_DOUBLE (asm_out_file, d);
  1919.  
  1920.       size = 0;
  1921. # endif
  1922.       set_float_handler (0);
  1923.     }
  1924.       break;
  1925.  
  1926.     case COMPLEX_TYPE:
  1927.       output_constant (TREE_REALPART (exp), size / 2);
  1928.       output_constant (TREE_IMAGPART (exp), size / 2);
  1929.       size -= (size / 2) * 2;
  1930.       break;
  1931.  
  1932.     case ARRAY_TYPE:
  1933.       if (TREE_CODE (exp) == CONSTRUCTOR)
  1934.     {
  1935.       output_constructor (exp, size);
  1936.       return;
  1937.     }
  1938.       else if (TREE_CODE (exp) == STRING_CST)
  1939.     {
  1940.       int excess = 0;
  1941.  
  1942.       if (size > TREE_STRING_LENGTH (exp))
  1943.         {
  1944.           excess = size - TREE_STRING_LENGTH (exp);
  1945.           size = TREE_STRING_LENGTH (exp);
  1946.         }
  1947.  
  1948. #if defined( DSP56000 ) || defined( DSP96000 )
  1949.       if (( ARRAY_TYPE == TREE_CODE ( TREE_TYPE ( exp ))) &&
  1950.           ( integer_type_node == TREE_TYPE ( TREE_TYPE ( exp ))))
  1951.       {
  1952.           int count = size;
  1953.           int *element = (int*) TREE_STRING_POINTER( exp );
  1954.           
  1955.           while ( 0 < count )
  1956.           {
  1957.           ASM_OUTPUT_INT ( asm_out_file, 
  1958.                   gen_rtx ( CONST_INT, VOIDmode, 
  1959.                        *( element ++ )));
  1960.  
  1961.           count -= sizeof( int );
  1962.           }
  1963.       }
  1964.       else
  1965.       {
  1966.           assemble_string (TREE_STRING_POINTER (exp), size);
  1967.       }
  1968. #else
  1969.       assemble_string (TREE_STRING_POINTER (exp), size);
  1970. #endif
  1971.       size = excess;
  1972.     }
  1973.       else
  1974.     abort ();
  1975.       break;
  1976.  
  1977.     case RECORD_TYPE:
  1978.     case UNION_TYPE:
  1979.       if (TREE_CODE (exp) == CONSTRUCTOR)
  1980.     output_constructor (exp, size);
  1981.       else
  1982.     abort ();
  1983.       return;
  1984.     }
  1985.  
  1986.   if (size > 0)
  1987.     ASM_OUTPUT_SKIP (asm_out_file, size);
  1988. }
  1989.  
  1990. /* Subroutine of output_constant, used for CONSTRUCTORs
  1991.    (aggregate constants).
  1992.    Generate at least SIZE bytes, padding if necessary.  */
  1993.  
  1994. void
  1995. output_constructor (exp, size)
  1996.      tree exp;
  1997.      int size;
  1998. {
  1999.   register tree link, field = 0;
  2000.   /* Number of bytes output or skipped so far.
  2001.      In other words, current position within the constructor.  */
  2002.   int total_bytes = 0;
  2003.   /* Non-zero means BYTE contains part of a byte, to be output.  */
  2004.   int byte_buffer_in_use = 0;
  2005.   register int byte;
  2006.  
  2007.   if (HOST_BITS_PER_INT < BITS_PER_UNIT)
  2008.     abort ();
  2009.  
  2010.   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
  2011.       || TREE_CODE (TREE_TYPE (exp)) == UNION_TYPE)
  2012.     field = TYPE_FIELDS (TREE_TYPE (exp));
  2013.  
  2014.   /* As LINK goes through the elements of the constant,
  2015.      FIELD goes through the structure fields, if the constant is a structure.
  2016.      But the constant could also be an array.  Then FIELD is zero.  */
  2017.   for (link = CONSTRUCTOR_ELTS (exp);
  2018.        link;
  2019.        link = TREE_CHAIN (link),
  2020.        field = field ? TREE_CHAIN (field) : 0)
  2021.     {
  2022.       tree val = TREE_VALUE (link);
  2023.  
  2024.       /* Eliminate the NOP_EXPR that makes a cast not be an lvalue.  */
  2025.       if (TREE_CODE (val) == NOP_EXPR
  2026.       && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0)))
  2027.     val = TREE_OPERAND (val, 0);
  2028.  
  2029.       if (field == 0
  2030.       || (DECL_MODE (field) != BImode))
  2031.     {
  2032.       register int fieldsize;
  2033.  
  2034.       /* An element that is not a bit-field.
  2035.          Output any buffered-up bit-fields preceding it.  */
  2036.       if (byte_buffer_in_use)
  2037.         {
  2038.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  2039.           total_bytes++;
  2040.           byte_buffer_in_use = 0;
  2041.         }
  2042.  
  2043.       /* Advance to offset of this element.
  2044.          Note no alignment needed in an array, since that is guaranteed
  2045.          if each element has the proper size.  */
  2046.       if (field != 0 && DECL_OFFSET (field) / BITS_PER_UNIT != total_bytes)
  2047.         {
  2048.           ASM_OUTPUT_SKIP (asm_out_file,
  2049.                    (DECL_OFFSET (field) / BITS_PER_UNIT
  2050.                 - total_bytes));
  2051.           total_bytes = DECL_OFFSET (field) / BITS_PER_UNIT;
  2052.         }
  2053.  
  2054.       /* Determine size this element should occupy.  */
  2055.       if (field)
  2056.         {
  2057.           if (! TREE_LITERAL (DECL_SIZE (field)))
  2058.         abort ();
  2059.           fieldsize = TREE_INT_CST_LOW (DECL_SIZE (field))
  2060.         * DECL_SIZE_UNIT (field);
  2061.           fieldsize = (fieldsize + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
  2062.         }
  2063.       else
  2064.         fieldsize = int_size_in_bytes (TREE_TYPE (TREE_TYPE (exp)));
  2065.  
  2066.       /* Output the element's initial value.  */
  2067.       output_constant (val, fieldsize);
  2068.  
  2069.       /* Count its size.  */
  2070.       total_bytes += fieldsize;
  2071.     }
  2072.       else if (TREE_CODE (val) != INTEGER_CST)
  2073.     error ("invalid initial value for member `%s'",
  2074.            IDENTIFIER_POINTER (DECL_NAME (field)));
  2075.       else
  2076.     {
  2077.       /* Element that is a bit-field.  */
  2078.  
  2079.       int next_offset = DECL_OFFSET (field);
  2080.       int end_offset
  2081.         = (next_offset
  2082.            + (TREE_INT_CST_LOW (DECL_SIZE (field))
  2083.           * DECL_SIZE_UNIT (field)));
  2084.  
  2085.       /* If this field does not start in this (or, next) byte,
  2086.          skip some bytes.  */
  2087.       if (next_offset / BITS_PER_UNIT != total_bytes)
  2088.         {
  2089.           /* Output remnant of any bit field in previous bytes.  */
  2090.           if (byte_buffer_in_use)
  2091.         {
  2092.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  2093.           total_bytes++;
  2094.           byte_buffer_in_use = 0;
  2095.         }
  2096.  
  2097.           /* If still not at proper byte, advance to there.  */
  2098.           if (next_offset / BITS_PER_UNIT != total_bytes)
  2099.         {
  2100.           ASM_OUTPUT_SKIP (asm_out_file,
  2101.                    next_offset / BITS_PER_UNIT - total_bytes);
  2102.           total_bytes = next_offset / BITS_PER_UNIT;
  2103.         }
  2104.         }
  2105.  
  2106.       if (! byte_buffer_in_use)
  2107.         byte = 0;
  2108.  
  2109.       /* We must split the element into pieces that fall within
  2110.          separate bytes, and combine each byte with previous or
  2111.          following bit-fields.  */
  2112.  
  2113.       /* next_offset is the offset n fbits from the begining of
  2114.          the structure to the next bit of this element to be processed.
  2115.          end_offset is the offset of the first bit past the end of
  2116.          this element.  */
  2117.       while (next_offset < end_offset)
  2118.         {
  2119.           int this_time;
  2120.           int next_byte = next_offset / BITS_PER_UNIT;
  2121.           int next_bit = next_offset % BITS_PER_UNIT;
  2122.  
  2123.           /* Advance from byte to byte
  2124.          within this element when necessary.  */
  2125.           while (next_byte != total_bytes)
  2126.         {
  2127.           ASM_OUTPUT_BYTE (asm_out_file, byte);
  2128.           total_bytes++;
  2129.           byte = 0;
  2130.         }
  2131.  
  2132.           /* Number of bits we can process at once
  2133.          (all part of the same byte).  */
  2134.           this_time = MIN (end_offset - next_offset,
  2135.                    BITS_PER_UNIT - next_bit);
  2136. #ifdef BYTES_BIG_ENDIAN
  2137.           /* On big-endian machine, take the most significant bits
  2138.          first (of the bits that are significant)
  2139.          and put them into bytes from the most significant end.  */
  2140.           byte |= (((TREE_INT_CST_LOW (val)
  2141.              >> (end_offset - next_offset - this_time))
  2142.             & ((1 << this_time) - 1))
  2143.                << (BITS_PER_UNIT - this_time - next_bit));
  2144. #else
  2145.           /* On little-endian machines,
  2146.          take first the least significant bits of the value
  2147.          and pack them starting at the least significant
  2148.          bits of the bytes.  */
  2149.           byte |= ((TREE_INT_CST_LOW (val)
  2150.             >> (next_offset - DECL_OFFSET (field)))
  2151.                & ((1 << this_time) - 1)) << next_bit;
  2152. #endif
  2153.           next_offset += this_time;
  2154.           byte_buffer_in_use = 1;
  2155.         }
  2156.     }
  2157.     }
  2158.   if (byte_buffer_in_use)
  2159.     {
  2160.       ASM_OUTPUT_BYTE (asm_out_file, byte);
  2161.       total_bytes++;
  2162.     }
  2163.   if (total_bytes < size)
  2164.     ASM_OUTPUT_SKIP (asm_out_file, size - total_bytes);
  2165. }
  2166.